<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">

<head>
    <base href="<%=basePath %>">
    <meta charset="UTF-8">
    <title>协助下单</title>
    <!-- load css -->
    <link rel="icon" href="image/common/logo.png" type="image/x-icon"/>
    <link rel="stylesheet" type="text/css" href="css/font/iconfont.css?v=1.0.0" media="all">
    <link rel="stylesheet" type="text/css" href="js/layui/css/layui.css" media="all">
    <link href="js/common/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css"/>
    <link href="js/common/cropper/cropper.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="js/common/jquery-1.11.3.js"></script>
    <script src="js/common/ztree/jquery.ztree.all.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/layui/layui.js"></script>
    <script type="text/javascript" src="js/jQueryFileUpload/js/vendor/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="js/jQueryFileUpload/js/jquery.iframe-transport.js"></script>
    <script type="text/javascript" src="js/jQueryFileUpload/js/jquery.fileupload.js"></script>
    <script type="text/javascript" src="js/common/cropper/cropper.js"></script>
    <script type="text/javascript">
        layui.config({
            base: "js/common/"
        }).use(["common", "layer"], function () {
            var layer = layui.layer;
            var $ = layui.jquery;
            layui.common.init();
        });
        var setting = {
            async: {
                enable: true, // 设置 zTree是否开启异步加载模式
                url: "XD020/tree.do?tmp=" + Math.random(),						 	// Ajax 获取数据的 URL 地址
                autoParam: ["id", "name=n", "level=lv"],		 	//异步加载时自动提交父节点属性的参数 , "name=n", "level=lv"
                type: "get",                                     	//提交方式
                dataFilter: filter
            },
            callback: {
                onClick: select
            }
        };

        function filter(treeId, parentNode, childNodes) {
            setNode(childNodes);
            return childNodes;
        }

        function setNode(nodes) {
            if (!nodes) return null;
            for (var i = 0, l = nodes.length; i < l; i++) {
                nodes[i].url = "";
                setNode(nodes[i].children);
            }
        }

        $(document).ready(function () {
            //生成zTree树
            $.fn.zTree.init($("#SysArea"), setting);

            $("#btnAddParent").on("click", function () {
                $.post($(this).attr("url"), addParentClass, "json");
            });

        });

        function select(event, treeId, treeNode) {
            $("#btnAddSub").show();
            $("#btnAddSub").unbind("click");
            $("#btnAddSub").bind("click", function () {
                $.post($(this).attr("url"), {areaId: treeNode.id, treeNodeLevel: treeNode.level}, addSubClass, "json");
            });
            $("#SysAreaDetails").load("xzxd/toMsg.do?areaId=" + treeNode.id);
        }


    </script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>服务点列表</legend>
</fieldset>
<div style="margin-top:10px;">
    <div style="float: left; display: block; margin: 0px 10px; overflow: auto; width: 240px;
        height: 763px; border: solid 1px #CCC; background: #FFF;">

        <div>
            <ul class="ztree" id="SysArea">
            </ul>
        </div>
    </div>
    <div id="SysAreaDetails" style="height: 763px;border: solid 1px #CCC ;background:#eee; margin-left: 256px;">
			
    </div>
</div>
</body>
</html>